package com.gmail.ceac13;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class ImagemOverlay extends Overlay {
	private Paint paint = new Paint();
	private final int imageId;
	private final GeoPoint geoPoint;
	public ImagemOverlay(GeoPoint geoPoint, int resId) {
		this.geoPoint = geoPoint;
		this.imageId = resId;
	}
	
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		super.draw(canvas, mapView, shadow);
		
		Point p = mapView.getProjection().toPixels(geoPoint, null);
		Bitmap bitmap = BitmapFactory.decodeResource(mapView.getResources(), this.imageId);
		RectF r = new RectF(p.x, p.y, p.x+bitmap.getWidth(),p.y+bitmap.getHeight());
		canvas.drawBitmap(bitmap, null, r, paint);
	}
}
